from typing import Optional

from sqlmodel import Field

from app.schemas.base import BaseSchema


class UserRoleBase(BaseSchema):
    """用户和角色关联表基础模型"""

    user_id: int = Field(default=..., description="用户ID", alias="userId")
    role_id: int = Field(default=..., description="角色ID", alias="roleId")


class UserRoleCreate(UserRoleBase):
    """创建用户和角色关联表模型"""

    pass


class UserRoleUpdate(UserRoleBase):
    """更新用户和角色关联表模型"""

    user_id: Optional[int] = Field(default=None, description="用户ID", alias="userId")
    role_id: Optional[int] = Field(default=None, description="角色ID", alias="roleId")


class UserRolePublic(UserRoleBase):
    """用户和角色关联表公开模型"""

    user_id: int = Field(alias="userId", description="用户ID")
    role_id: int = Field(alias="roleId", description="角色ID")
